import httpFetch from 'share/httpFetch'
import errorMessage from "share/errorMessage";

export default {

  getPinnedList(tableName) {
    return httpFetch.get('/api/queryCriteria', { tableName })
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  setPinnedList(tableName, pinnedList) {
    return httpFetch.post(`/api/queryCriteria?tableName=${tableName}`, pinnedList)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  getConditionList(tableName) {
    return httpFetch.get('/api/customizedQuery', { tableName })
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  setCondition(params) {
    return httpFetch.post('/api/customizedQuery', params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  getConditionById(id) {
    return httpFetch.get('/api/customizedQuery/id', { id })
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  }

}
